import { createRouter, createWebHistory } from 'vue-router';


import index from '@/views/index.vue'; 
import indexVue from '@/views/index/index.vue'; 
import BusinessVue from '@/views/business/Business.vue'; 
import ServiceVue from '@/views/index/Service.vue'; 
import ExhibitionVue from '@/views/index/Exhibition.vue'; 
import AboutVue from '@/views/about/About.vue'; 
import ContantVue from '@/views/index/Contant.vue'; 
import NewVue from '@/views/index/New.vue'; 
import CaseVue from '@/views/index/Case.vue'; 

 //双清专线
import businessChildren from './business.js'; // 导入业务路由的 children


const routes = [
  {
    path: '/',
    name: 'index',
    component: index,
    children: [
      {
        path: '', // 这个空路径会匹配父路由的路径 /
        component: indexVue,
      },
      {
        path: 'business', // 这里是子路由的路径，访问 /business 将渲染 Business 组件
        name: 'business',
        component: BusinessVue,
        children: businessChildren
      },
      {
        path: 'service', 
        name: 'service',
        component: ServiceVue,
      },
      {
        path: 'about', 
        name: 'about',
        component: AboutVue,
      },
      {
        path: 'contant', 
        name: 'contant',
        component: ContantVue,
      },
      {
        path: 'exhibition', 
        name: 'exhibition',
        component: ExhibitionVue,
      },
      {
        path: 'new', 
        name: 'new',
        component: NewVue,
      },
      {
        path: 'case', 
        name: 'case',
        component: CaseVue,
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
  scrollBehavior(to, from, savedPosition) {
    return { top: 0 }; // 每次导航都滚动到顶部
  },
});

export default router;